#include "stdafx.h"
#include "FlyRotateLgSprite.h"

FlyRotateLgSprite::FlyRotateLgSprite(float nSpeed,float th,float centerx,float centery,float ro,
									 const vector<RectInBalloonElemnet_t>& listRect):
m_nSpeed(D3DXToRadian(nSpeed)),m_th(D3DXToRadian(th)),m_centerx(centerx),m_centery(centery),m_ro(ro)
{
	m_eClassName=eFlyRotateLgSprite;
	m_vecHitRect.assign(listRect.begin(),listRect.end());
	m_vPosition=D3DXVECTOR2(centerx,centery);
}

FlyRotateLgSprite::~FlyRotateLgSprite()
{

}

void FlyRotateLgSprite::Update(DWORD dwCurrentTime)
{
	if(!m_bShow) return;
	DynamicLgSprite::Update(dwCurrentTime);

	m_th += m_nSpeed * m_fAnimationTimer/1000;   
	if( m_th >= D3DX_PI*2 ){
		m_th -= D3DX_PI*2;
	}
	
	m_vPosition.x=m_centerx+m_ro*cos(m_th);
	m_vPosition.y=m_centery+m_ro*sin(m_th);
	m_fAnimationTimer=0;
}
D3DXVECTOR2 FlyRotateLgSprite::GetCurrentNormalDirection()
{
	D3DXVECTOR2 d;
	d.x=cos(m_th);
	d.y=sin(m_th);
	return d;
}